}
}
-static double parse_leasetime(struct blob_attr *c) {
+static uint32_t parse_leasetime(struct blob_attr *c) {
char *val = blobmsg_get_string(c), *endptr = NULL;
- double time = strcmp(val, "infinite") ? strtod(val, &endptr) : UINT32_MAX;
+ uint32_t time = strcmp(val, "infinite") ? (uint32_t)strtod(val, &endptr) : UINT32_MAX;
if (time && endptr && endptr[0]) {
switch(endptr[0]) {
return time;
err:
- return -1;
+ return 0;
}
static void free_lease(struct lease *l)
}
if ((c = tb[LEASE_ATTR_LEASETIME])) {
- double time = parse_leasetime(c);
- if (time < 0)
+ uint32_t time = parse_leasetime(c);
+ if (time == 0)
goto err;
l->leasetime = time;
iface->no_dynamic_dhcp = !blobmsg_get_bool(c);
if ((c = tb[IFACE_ATTR_LEASETIME])) {
- double time = parse_leasetime(c);
+ uint32_t time = parse_leasetime(c);
- if (time >= 0)
+ if (time > 0)
iface->dhcp_leasetime = time;
else
syslog(LOG_ERR, "Invalid %s value configured for interface '%s'",
}
if ((c = tb[IFACE_ATTR_MAX_PREFERRED_LIFETIME])) {
- double time = parse_leasetime(c);
+ uint32_t time = parse_leasetime(c);
- if (time >= 0) {
+ if (time > 0)
iface->max_preferred_lifetime = time;
- } else {
+ else
syslog(LOG_ERR, "Invalid %s value configured for interface '%s'",
iface_attrs[IFACE_ATTR_MAX_PREFERRED_LIFETIME].name, iface->name);
- }
+
}
if ((c = tb[IFACE_ATTR_MAX_VALID_LIFETIME])) {
- double time = parse_leasetime(c);
+ uint32_t time = parse_leasetime(c);
- if (time >= 0) {
+ if (time > 0)
iface->max_valid_lifetime = time;
- } else {
+ else
syslog(LOG_ERR, "Invalid %s value configured for interface '%s'",
iface_attrs[IFACE_ATTR_MAX_VALID_LIFETIME].name, iface->name);
- }
+
}
if ((c = tb[IFACE_ATTR_START])) {